package model.dao;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import model.vo.mycinema.BoardVO;
import model.vo.mycinema.MemberVO;
import model.vo.reservation.ReservationVO;

import com.ibatis.sqlmap.client.SqlMapClient;

public class MyCinemaDao {
	private SqlMapClient sqlMapClient;

	public void setSqlMapClient(SqlMapClient sqlMapClient) {
		this.sqlMapClient = sqlMapClient;
	}
	public void registerMember(MemberVO vo) throws SQLException{		
		sqlMapClient.insert("mycinema.registerMember",vo);
	}
	public Object idcheck(String id) throws SQLException{
		return sqlMapClient.queryForObject("mycinema.idcheck",id);			
	}
	public Object login(MemberVO vo) throws SQLException{
		return sqlMapClient.queryForObject("mycinema.login", vo);
	}
	public List<BoardVO> getBoardList(String pageNo) throws SQLException{
		System.out.println("왜 안보이냐??");
		return sqlMapClient.queryForList("mycinema.getBoardList", pageNo);
	}
	public int totalContent() throws SQLException{
		return (Integer)sqlMapClient.queryForObject("mycinema.totalContent");
	}
	public int write(BoardVO bvo) throws SQLException{
		return (Integer) sqlMapClient.insert("mycinema.write", bvo);
	}
	public String selectByNoForDate(int board_no) throws SQLException{
		return (String)sqlMapClient.queryForObject("mycinema.selectByNoForDate",board_no);
	}
	public BoardVO show(String board_no) throws SQLException{
		System.out.println("왜~~~~~~안되는 거야~~~~"+""+"show");
		return (BoardVO)sqlMapClient.queryForObject("mycinema.show",board_no);
	}
	public void updateCount(String no) throws SQLException{
		//System.out.println("안되니??"+"updateCount");
		sqlMapClient.update("mycinema.updateCount", no);
	}
	public void updateBoard(BoardVO bvo) throws SQLException{
		//System.out.println("알았어~~");
		sqlMapClient.update("mycinema.updateBoard", bvo);
	}
	public void deleteBoard(String no) throws SQLException{
		sqlMapClient.delete("mycinema.deleteBoard", no);		
	}
	public int updateRestep(int ref, int restep) throws SQLException{
		//System.out.println("답변 끝나갑니다.");
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		map.put("ref", ref);
		map.put("restep", restep);
		/*System.out.println("operation");
		System.out.println(map.get("ref")+"확인");
		System.out.println(map.get("restep")+"확인");
		System.out.println(map);*/
		int cnt = sqlMapClient.update("mycinema.updateRestep", map);
		//System.out.println(cnt+"updateRestep");
		return cnt;
	}
	public int insertRefContent(BoardVO bvo) throws SQLException{
		//System.out.println("답변 거의 끝");
		int no = (Integer)sqlMapClient.insert("mycinema.writeRef", bvo);
		//System.out.println(no+"insertRefContent");
		return no;
	}
	public void updateMember(MemberVO vo) throws SQLException{
		sqlMapClient.update("mycinema.updateMember", vo);
	}
	public MemberVO findId(MemberVO vo) throws SQLException{
		//System.out.println("아이디+2 ");
		return (MemberVO)sqlMapClient.queryForObject("mycinema.findId", vo);
	}
	public MemberVO findPa(MemberVO vo) throws SQLException{
		return (MemberVO)sqlMapClient.queryForObject("mycinema.findPa", vo);
	}
	public Object ssnCheck(String ssn) throws SQLException{
		//System.out.println("ssn 찾기");
		return sqlMapClient.queryForObject("mycinema.ssnCheck", ssn);
	}
	public void deleteMember(MemberVO vo) throws SQLException{
		System.out.println("delete+dao");
		sqlMapClient.delete("mycinema.deleteMember", vo);
	}public void deleteReservationMember(int member_no) throws SQLException{
		System.out.println("Reservation Member del");
		sqlMapClient.delete("mycinema.deleteReservationMember",member_no);
	}public void deleteBoardMember(int member_no) throws SQLException{
		System.out.println("Board Member del");
		sqlMapClient.delete("mycinema.deleteBoardMember",member_no);
	}public List<Map> getAllMyHistory(Map map) throws SQLException {
		return sqlMapClient.queryForList("mycinema.getAllMyHistory",map);
	}
	public int getTotalAllMyHistory(int member_no) throws SQLException {
		return (int) sqlMapClient.queryForObject("mycinema.getTotalAllMyHistory",member_no);
	}
	public List<Map> getBuyMyHistory(Map map) throws SQLException {
		return sqlMapClient.queryForList("mycinema.getBuyMyHistory",map);
	}
	public int getTotalBuyMyHistory(int member_no) throws SQLException {
		return (int) sqlMapClient.queryForObject("mycinema.getTotalBuyMyHistory",member_no);
	}
	public List<Map> getSellMyHistory(Map map) throws SQLException {
		return sqlMapClient.queryForList("mycinema.getSellMyHistory",map);
	}
	public int getTotalSellMyHistory(int member_no) throws SQLException {
		return (int) sqlMapClient.queryForObject("mycinema.getTotalSellMyHistory",member_no);
	}
}
